package icu.lookyousmileface.review;

/**
 * @author starrysky
 * @title: ReviewSync
 * @projectName Juc_Pro
 * @description: sync
 * @date 2021/1/2912:50 上午
 */
public class ReviewSync {
    public static void main(String[] args) {
        //资源类
        Takits takits = new Takits();
        //线程
        new Thread(()->{
            for (int i = 1; i < 66; i++) {
                takits.sale();
            }
        },"A").start();
        new Thread(()->{
            for (int i = 1; i < 66; i++) {
                takits.sale();
            }
        },"B").start();
        new Thread(()->{
            for (int i = 1; i < 66; i++) {
                takits.sale();
            }
        },"C").start();
    }
}
class Takits{
    private int tick =66;
    public synchronized void sale(){
        if (tick>0){
            System.out.println(Thread.currentThread().getName()+":"+(tick--)+"还剩："+tick);
        }
    }
}
